package com.kamisama.utopia.respond;

import static com.kamisama.utopia.constant.character.Charm.formatCharm;
import static com.kamisama.utopia.constant.character.Energy.formatEnergy;
import static com.kamisama.utopia.constant.character.Experience.formatExperience;
import static com.kamisama.utopia.constant.character.Faith.formatFaith;
import static com.kamisama.utopia.constant.character.Healthy.formatHealthy;
import static com.kamisama.utopia.constant.character.Hygiene.formatHygiene;
import static com.kamisama.utopia.constant.character.Magic.formatMagic;
import static com.kamisama.utopia.constant.character.Mood.formatMood;
import static com.kamisama.utopia.constant.character.Satiety.formatSatiety;
import static com.kamisama.utopia.constant.character.Sense.formatSense;
import static com.kamisama.utopia.constant.character.Strength.formatStrength;

import com.kamisama.utopia.entity.Attribute;
import com.kamisama.utopia.entity.Character;
import org.springframework.util.StringUtils;

public class RespondTemplate {
    public static String formatCharacterRespond(Character character){
        String respondTemplate
            =   formatExperience(character.getExperience()) +
                character.getName() + "你的当前数据：\n" +
                "资本：存款"+ character.getDeposit().getBank() + "/现金" + character.getDeposit().getCash() + "\n" +
                "经验：" + character.getExperience() + "\n" +
                "种族：" + character.getRace() + "\n" +
                "性别：" + character.getSex() + "\n" +
                formatAttribute(character.getAttribute()) +
                formatLocation(character.getLocation()) +
                formatGods(character.getGods()) +
                formatSpouse(character.getSpouseName());
        return respondTemplate;
    }

    private static String formatSpouse(String spouse) {
        if (StringUtils.isEmpty(spouse)){
            return "";
        } else {
            return "配偶：" + spouse;
        }
    }

    private static String formatGods(String gods) {
        if (StringUtils.isEmpty(gods)){
            return "";
        } else {
            return "主神：" + gods + "\n";
        }
    }

    private static String formatLocation(String location) {
        return "位置：" + location + "\n";
    }

    private static String formatAttribute(Attribute attribute) {
        String attributeTemplate
            =   formatSatiety(attribute.getSatiety().intValue()) +
                formatStrength(attribute.getStrength().intValue()) +
                formatEnergy(attribute.getEnergy().intValue()) +
                formatHealthy(attribute.getHealthy().intValue()) +
                formatCharm(attribute.getCharm().intValue()) +
                formatMagic(attribute.getMagic()) +
                formatSense(attribute.getSense().intValue()) +
                formatHygiene(attribute.getHygiene().intValue()) +
                formatFaith(attribute.getFaith().intValue()) +
                formatMood(attribute.getMood().intValue());
        return attributeTemplate;
    }
}
